package com.jsu.user.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.example.model.user.pojo.User;

import java.util.List;

@Mapper
public interface WebUserMapper extends BaseMapper<User> {
    @Select("SELECT * FROM user_info WHERE tel = #{tel}")
    User selectByPhone(@Param("tel") String tel);

    @Select("SELECT pk_id FROM user_info WHERE tel = #{tel}")
    Integer selectIdByPhone(@Param("tel") String tel);

    @Select("SELECT % FROM user_info WHERE pk_id = #{pk_id}")
    User selectUserByID(@Param("tel") Integer pk_id);


    @Select("SELECT * FROM user_info WHERE username LIKE CONCAT('%', #{keyword}, '%') " +
            "OR position LIKE CONCAT('%', #{keyword}, '%') " +
            "OR pk_id LIKE CONCAT('%', #{keyword}, '%') " +
            "OR department LIKE CONCAT('%', #{keyword}, '%') " +
            "OR company LIKE CONCAT('%', #{keyword}, '%') " +
            "OR email LIKE CONCAT('%', #{keyword}, '%') " +
            "OR tel LIKE CONCAT('%', #{keyword}, '%') " +
            "OR statue LIKE CONCAT('%', #{keyword}, '%')")
    List<User> searchUsersByKeyword(@Param("keyword") String keyword);
}
